package com.jml.redis.controller;

import com.jml.redis.service.RedisService;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RedisController {

	@Autowired
	private RedisService redisService;

	@RequestMapping("/setRedisString")
	public String setRedisString(String key,String value){
		redisService.setObject(key,value);
		return "success";
	}

	@RequestMapping("/setRedisList")
	public String setRedisList(String key){
		List<String> redisList = new ArrayList<String>();
		redisList.add("123");
		redisList.add("jml");
		redisList.add("456");
		redisService.setObject(key,redisList);
		return "success";
	}

	@RequestMapping("/getByKey")
	public String getByKey(String key){
		String string = redisService.getString(key);
		return string;
	}
}
